import { lazy, Suspense } from 'react' /* 路由懒加载模块 */
import { useRoutes, Navigate } from 'react-router'
const Home = lazy(() =>
  import('../views/Home/Home')
) /* 导入需要懒加载的路由需要使用lazy */
const Login = lazy(() => import('../views/Login/Login'))
const Routerviews = () => {
  const routes = useRoutes([
    {
      path: '/',
      element: <Navigate to="/home"></Navigate>,
    },
    {
      path: '/home',
      element: (
        <Suspense fallback={<div>loading</div>}>
          <Home />
        </Suspense>
      ),
    },
    {
      path: '/login',
      element: (
        <Suspense fallback={<div>loading</div>}>
          <Login />
        </Suspense>
      ),
    },
  ])
  return routes
}
export default Routerviews
